import vue from "@vitejs/plugin-vue";
import coffee from "@rmw/vite-plugin-coffee";
import pug from "rollup-plugin-pug";
import {
  defineConfig
} from "vite";

export default defineConfig(({
  mode
}) => {
  const isDev = mode !== 'production';
  let {
    pathname
  } = new URL(
    import.meta.url);
  pathname = pathname.replace(/\\/g, "/");
  return {
    worker: {
      format: 'es',
      plugins: [
        coffee({
          bare: true,
          sourceMap: true,
        }),
      ]
    },
    base: isDev ? "/" : "",
    plugins: [
      coffee({
        bare: true,
        sourceMap: true,
      }),
      pug(),
      vue(),
    ],
    resolve: {
      alias: {
        "~": pathname.slice(0, pathname.lastIndexOf("/") + 1) + "src",
      },
    },
    build: {
      assetsDir: ""
    }
    /*
    css: {
      preprocessorOptions: {
        less: {
          modifyVars: {
            "border-radius-small": "0",
            "border-radius-medium": "0",
            "border-radius-large": "0",
            "primary-6": "#000",
          },
          javascriptEnabled: true,
        },
      },
    },
    */
  };
});
